//
//  XJBuyInfoTableViewCell.m
//  XinJiangMall
//
//  Created by RaoBo on 2018/5/11.
//  Copyright © 2018年 Tzyang. All rights reserved.
//

#import "XJBuyInfoTableViewCell.h"

// Model
#import "XJBuyInfoModel.h"

@interface XJBuyInfoTableViewCell()
/**商品icon*/
@property (weak, nonatomic) IBOutlet UIImageView *goodIconIV;
/**价格*/
@property (weak, nonatomic) IBOutlet UILabel *priceLb;
/**库存*/
@property (weak, nonatomic) IBOutlet UILabel *kuCunLb;
/**已选套餐:*/
@property (weak, nonatomic) IBOutlet UILabel *selectedInfoLb;

@end
@implementation XJBuyInfoTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

/**点击取消按钮*/
- (IBAction)cancalAction:(UIButton *)sender {
    
    if (self.xjCancelBlock) {
        self.xjCancelBlock();
    }
}


#pragma mark - 接口
//- (void)updateStock:(NSString *)stock haveChosen:(NSString *)str {
//    self.kuCunLb.text = [NSString stringWithFormat:@"库存:%@",stock];
//    self.selectedInfoLb.text = [NSString stringWithFormat:@"已选:%@",str];
//}

- (void)setBuyModel:(XJBuyInfoModel *)buyModel {
    _buyModel = buyModel;
    
    NSURL *imgUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@",buyModel.cover]];
    
    [self.goodIconIV sd_setImageWithURL:imgUrl placeholderImage:[UIImage imageNamed:@"default_goods"]];
    
    self.priceLb.text = [NSString stringWithFormat:@"￥%.2f",[buyModel.price floatValue]];
    
    if ([NSString isEmptyString:buyModel.stock]) { // 如果为 空 就不拼接 解决 库存:<null>
        self.kuCunLb.text = [NSString stringWithFormat:@"库存:"];
    }else {
        self.kuCunLb.text = [NSString stringWithFormat:@"库存:%@",buyModel.stock];
    }
    
    if ([NSString isEmptyString:buyModel.chosenStr]) {
        self.selectedInfoLb.text = [NSString stringWithFormat:@"已选:"];
    }else {
        self.selectedInfoLb.text = [NSString stringWithFormat:@"已选:%@",buyModel.chosenStr];
    }
    
}
@end
